﻿using Easy.Services.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Easy.Services.Config
{
    /// <summary>
    /// UserConfig
    /// </summary>
    class UserConfig : IEntityTypeConfiguration<User>
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
            builder.ToTable(nameof(User));

            builder.Property(u => u.CreaterId).IsRequired(false);
            builder.Property(u => u.CreaterName).HasMaxLength(50).IsRequired(false);
            builder.Property(u => u.EditDate).IsRequired(false);
            builder.Property(u => u.EditId).IsRequired(false);
            builder.Property(u => u.EditName).HasMaxLength(50).IsRequired(false);
            builder.Property(r => r.IsDelete).IsRequired(false);

            builder.Property(u => u.City).HasMaxLength(200).IsRequired(false);
            builder.Property(u => u.Company).HasMaxLength(200).IsRequired(false);
            builder.Property(u => u.CompanyId).IsRequired(false);
            builder.Property(u => u.CorrectionTime).HasMaxLength(20).IsRequired(false);
            builder.Property(u => u.CreateIP).HasMaxLength(100).IsRequired(false);
            builder.Property(u => u.DepartmentName).HasMaxLength(100).IsRequired(false);
            builder.Property(u => u.DepartmentId).IsRequired(false);
            builder.Property(u => u.Email).HasMaxLength(100).IsRequired(false);
            builder.Property(u => u.FormOfEmployment).IsRequired(false);
            builder.Property(u => u.Gender).HasComment("性别").IsRequired(false);
            builder.Property(u => u.Mobile).HasMaxLength(20).HasComment("手机").IsRequired(false);
            builder.Property(u => u.IsFreeze).IsRequired(false);
            builder.Property(u => u.LoginErrorCount).HasDefaultValue(0).IsRequired(false);
            builder.Property(u => u.LoginTotalCount).HasDefaultValue(0).IsRequired(false);
            builder.Property(u => u.Password).HasMaxLength(50).IsRequired();
            builder.Property(u => u.PasswordSalt).HasMaxLength(50).IsRequired();
            builder.Property(ui => ui.StaffPhoto).HasMaxLength(200).IsRequired(false);
            builder.Property(u => u.Summary).HasMaxLength(255).IsRequired(false);
            builder.Property(u => u.TimeOfEntry).HasMaxLength(20).IsRequired(false);
            builder.Property(u => u.UserName).HasMaxLength(50).IsRequired(false);
            builder.Property(u => u.WorkNumber).HasMaxLength(50).IsRequired(false);


        }
    }
}